package com.example.practice.service.impl;

import com.example.practice.entity.*;
import com.example.practice.dao.MiddleSchoolDao;
import com.example.practice.service.MiddleSchoolService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (MiddleSchool)表服务实现类
 *
 * @author makejava
 * @since 2023-12-29 11:02:00
 */
@Service("middleSchoolService")
public class MiddleSchoolServiceImpl implements MiddleSchoolService {
    @Resource
    private MiddleSchoolDao middleSchoolDao;

    @Override
    public respMsg getAllByUidPage(Integer uid, pageMsg pageMsg) {
        PageHelper.startPage(pageMsg.getPage(), pageMsg.getSize());
        List<MiddleSchool> middleSchools = this.middleSchoolDao.queryAllByUid(uid);
        PageInfo<MiddleSchool> middleSchoolPageInfo = new PageInfo<>(middleSchools);
        return new respMsg(1, null, middleSchools, middleSchoolPageInfo.getTotal());
    }

    @Override
    public List<MiddleSum> getSumByUid(Integer uid) {
        List<MiddleSum> middleSums = this.middleSchoolDao.getSumByUid(uid);
        return middleSums;
    }

    @Override
    public List<AdmiYear> getAdmission(Integer mid, Integer uid) {
        return this.middleSchoolDao.getAdmission(mid, uid);
    }

    @Override
    public List<MiddleSchool> getMiddleSchool(){return this.middleSchoolDao.getMiddleSchool();}

    @Override
    public List<MiddleSchool> joinMiddleSchool(Integer aid){return this.middleSchoolDao.joinMiddleSchool(aid);}

    @Override
    public Integer insertMiddleSchool(List<MiddleSchool> middleSchools) {
        return this.middleSchoolDao.insertMiddleSchool(middleSchools);
    }

    @Override
    public Integer insertAdmission(List<Admission> admissions) {
        return this.middleSchoolDao.insertAdmission(admissions);
    }

    @Override
    public List<MiddleSchool> getAllAdmiByUid(Integer uid) {
        return this.middleSchoolDao.queryAllByUid(uid);
    }
}
